<template>
    <div class="dialog">
        <a-modal
            v-drag-modal
            class="opinionDialog"
            title="评审意见"
            :visible="visible"
            @cancel="handleCancel"
            :maskClosable="false"
        >
            <template slot="footer">
                <a-button type="primary" html-type="submit" @click="onSubmit">确定</a-button>
            </template>
            <div class="dialogCont">
                <a-form-model
                    ref="ruleForm"
                    :model="queryParam"
                    :rules="ruleValidate"
                >
                    <a-form-model-item ref="opinion" label="" prop="opinion">
                        <a-input placeholder="请输入评审意见" v-model="queryParam.opinion" type="textarea" :auto-size="{ minRows: 5}"/>
                    </a-form-model-item>
                </a-form-model>
            </div>
        </a-modal>
    </div>
</template>
<script>
export default {
    props: ['showFlag', 'opinion'],
    data() {
        return {
            visible: false,
            queryParam: {
                opinion: ''
            },
            ruleValidate: {
                opinion: [
                    { required: true, message: '请输入评审意见', trigger: 'blur' }
                ]
            },
        }
    },
    watch: {
        showFlag(next, prev) {
            if (next != prev) {
                var self = this
                console.log('意见框', self.opinion)
                self.queryParam.opinion = self.opinion ? self.opinion : ''
                self.visible = !self.visible
            }
        }
    },
    methods: {
        onSubmit() {
            let self = this
            self.$refs.ruleForm.validate((valid, value) => {
                if (valid) {
                    console.log('校验通过', self.queryParam.opinion)
                    self.$emit('updateOpinion', self.queryParam.opinion)
                } else {
                    return false
                }
            })
        },
        handleCancel() {
            this.$refs.ruleForm.resetFields()
            this.visible = false
        }
    }
}
</script>
<style lang="less" scoped>
    
</style>
